package cn.funnymap.lgis.mp.entity;

import cn.funnymap.lgis.params.CommonPageQueryRequest;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * @author jiaoxn
 */
@Data
public class BaseEntityLogicByInteger implements Serializable {
    private static final long serialVersionUID = 1L;

    private Integer isVisible;
    @TableLogic(value = "0", delval = "1")
    private Integer isDeleted;

    @TableField(value = "creator_id", fill = FieldFill.INSERT)
    private String creatorId;
    @TableField(value = "creator_name", fill = FieldFill.INSERT)
    private String creatorName;
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    @TableField(value = "updater_id", fill = FieldFill.INSERT)
    private String updaterId;
    @TableField(value = "updater_name", fill = FieldFill.INSERT)
    private String updaterName;
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @Version
    private Integer version;

    public static <T extends BaseEntity> IPage<T> getPage(CommonPageQueryRequest pageQueryRequest) {
        return new Page<>(pageQueryRequest.getPage(), pageQueryRequest.getPageSize());
    }
}
